using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using CrazyControl.Controls.Container;
using APP.QUANLY.Provider;

namespace QLKho.GUI
{
    public partial class uc_ButtonMatHang : UserControl
    {
        public uc_ButtonMatHang()
        {
            InitializeComponent();
        }
        public event MatHangClickHandler MatHangEvent;

        #region field
        private Int32 _MaSP;
        private String _TenSP;
        private Image _HinhSP;
        private String _GiaLeSP;
        private String _GiaNhap;
        private String _GiaQuyDinh;
        private String _GiaChiaThang;
        private String _GiaKhuyenMai;
        private String _QuyCach;
        private String _VAT;
        private String _MaLoai;
        private String _MaDonViSi;
        private String _MaDonViLe;
        private String _TenDonViSi;
        private String _TenDonViLe;
        private String _SoLuongConLai;
        private String _NguongNhap;
        private String _NguongXuat;
        private Boolean _KhuyenMai;
        private Boolean _TrangThai;
        #endregion

        #region Property
        public Int32 MaSP
        {
            get { return _MaSP; }
            set
            {
                _MaSP = value;
                this.Name = _MaSP.ToString();
                picHinhSP.Name = _MaSP.ToString();
            }
        }
        public String TenSP
        {
            get { return _TenSP; }
            set
            {
                _TenSP = value;
                lblTenSP.Text = value;
            }
        }
        public Image HinhSP
        {
            get { return _HinhSP; }
            set
            {
                _HinhSP = value;
                picHinhSP.Image = value;
            }
        }
        public String GiaLeSP
        {
            get { return _GiaLeSP; }
            set { _GiaLeSP = value; lblGiaLeSP.Text = value; }
        }
        public String GiaNhap
        {
            get { return _GiaNhap; }
            set { _GiaNhap = value; lblGiaLeSP.Tag += value + ","; }
        }
        public String GiaQuyDinh
        {
            get { return _GiaQuyDinh; }
            set
            {
                _GiaQuyDinh = value; lblGiaLeSP.Tag += value + ",";
            }
        }
        public String GiaChiaThang
        {
            get { return _GiaChiaThang; }
            set { _GiaChiaThang = value; lblGiaLeSP.Tag += value + ","; }
        }
        public String GiaKhuyenMai
        {
            get { return _GiaKhuyenMai; }
            set { _GiaKhuyenMai = value; lblGiaLeSP.Tag += value + ","; }
        }
        public String QuyCach
        {
            get { return _QuyCach; }
            set { _QuyCach = value; }
        }
        public String VAT
        {
            get { return _VAT; }
            set { _VAT = value; }
        }
        public String MaLoai
        {
            get { return _MaLoai; }
            set { _MaLoai = value; }
        }
        public String MaDonViSi
        {
            get { return _MaDonViSi; }
            set { _MaDonViSi = value; }
        }
        public String MaDonViLe
        {
            get { return _MaDonViLe; }
            set { _MaDonViLe = value; }
        }
        public String TenDonViSi
        {
            get { return _TenDonViSi; }
            set { _TenDonViSi = value; }
        }
        public String TenDonViLe
        {
            get { return _TenDonViLe;  }
            set { _TenDonViLe = value; }
        }
        public String SoLuongConLai
        {
            get { return _SoLuongConLai; }
            set { _SoLuongConLai = value; lblSoLuongConLai.Text = value; }
        }
        public String NguongNhap
        {
            get { return _NguongNhap; }
            set { _NguongNhap = value; }
        }
        public String NguongXuat
        {
            get { return _NguongXuat; }
            set { _NguongXuat = value; }
        }
        public bool KhuyenMai
        {
            get { return _KhuyenMai; }
            set { _KhuyenMai = value; }
        }
        public bool TrangThai
        {
            get { return _TrangThai; }
            set { _TrangThai = value; }
        }
        #endregion 

        private void uc_ButtonMatHang_MouseEnter(object sender, EventArgs e)
        {
            this.picHinhSP.BackColor = Color.Orange;
            this.lblTenSP.BackColor = Color.Orange;
        }
        private void uc_ButtonMatHang_MouseLeave(object sender, EventArgs e)
        {
            this.picHinhSP.BackColor = Color.White;
            this.lblTenSP.BackColor = Color.Transparent;
        }

        //private void uc_ButtonMatHang_DoubleClick(object sender, EventArgs e)
        //{
        //    if (e != null)
        //        base.OnDoubleClick(e);
        //}

        //protected override void OnControlAdded(ControlEventArgs e)
        //{
        //    e.Control.DoubleClick += uc_ButtonMatHang_DoubleClick;
        //    base.OnControlAdded(e);
        //}

        #region Delegate UserControl Click
        public delegate void MatHangClickHandler(object sender, MatHangArgs mhArgs);
        private void InvokeMatHangClick(MatHangArgs mhArgs)
        {
            MatHangClickHandler _mhevent = MatHangEvent;
            if (_mhevent != null) _mhevent(this, mhArgs);
        }
        public class MatHangArgs : EventArgs
        {
            private Int32 _MaSP;
            private String _TenSP;
            private Image _HinhSP;
            private String _GiaLeSP;
            private String _GiaNhap;
            private String _GiaQuyDinh;
            private String _GiaChiaThang;
            private String _GiaKhuyenMai;
            private String _QuyCach;
            private String _VAT;
            private String _MaLoai;
            private String _MaDonViSi;
            private String _MaDonViLe;
            private String _TenDonViSi;
            private String _TenDonViLe;
            private String _SoLuongConLai;
            private String _NguongNhap;
            private String _NguongXuat;
            private Boolean _KhuyenMai;
            private Boolean _TrangThai;

            public MatHangArgs()
            {

            }
            public MatHangArgs(Int32 MaSP, string TenSP, Image HinhSP, string GiaLeSP, string GiaNhap, string GiaQuyDinh, string GiaChiaThang, string GiaKhuyenMai, string QuyCach, string VAT, string MaLoai, string MaDonViSi, string MaDonViLe, string TenDonViSi, string TenDonViLe, string SoLuongConLai,string NguongNhap,string NguongXuat,bool KhuyenMai, bool TrangThai)
            {
                _MaSP = MaSP;
                _TenSP = TenSP;
                _HinhSP = HinhSP;
                _GiaLeSP = GiaLeSP;
                _GiaNhap = GiaNhap;
                _GiaQuyDinh = GiaQuyDinh;
                _GiaChiaThang = GiaChiaThang;
                _GiaKhuyenMai = GiaKhuyenMai;
                _QuyCach = QuyCach;
                _VAT = VAT;
                _MaLoai = MaLoai;
                _MaDonViSi = MaDonViSi;
                _MaDonViLe = MaDonViLe;
                _TenDonViLe = TenDonViSi;
                _TenDonViLe = TenDonViLe;
                _SoLuongConLai = SoLuongConLai;
                _NguongNhap = NguongNhap;
                _NguongXuat = NguongXuat;
                _KhuyenMai = KhuyenMai;
                _TrangThai = TrangThai;
            }

            public Int32 MaSP
            {
                get { return _MaSP; }
                set { _MaSP = value; }
            }
            public String TenSP
            {
                get { return _TenSP; }
                set { _TenSP = value; }
            }
            public Image HinhSP
            {
                get { return _HinhSP; }
                set { _HinhSP = value; }
            }
            public String GiaLeSP
            {
                get { return _GiaLeSP; }
                set { _GiaLeSP = value; }
            }
            public String GiaNhap
            {
                get { return _GiaNhap; }
                set { _GiaNhap = value; }
            }
            public String GiaQuyDinh
            {
                get { return _GiaQuyDinh; }
                set { _GiaQuyDinh = value; }
            }
            public String GiaChiaThang
            {
                get { return _GiaChiaThang; }
                set { _GiaChiaThang = value; }
            }
            public String GiaKhuyenMai
            {
                get { return _SoLuongConLai; }
                set { _SoLuongConLai = value; }
            }
            public String QuyCach
            {
                get { return _QuyCach; }
                set { _QuyCach = value; }
            }
            public String VAT
            {
                get { return _VAT; }
                set { _VAT = value; }
            }
            public String MaLoai
            {
                get { return _MaLoai; }
                set { _MaLoai = value; }
            }
            public String MaDonViSi
            {
                get { return _MaDonViSi; }
                set { _MaDonViSi = value; }
            }
            public String MaDonViLe
            {
                get { return _MaDonViLe; }
                set { _MaDonViLe = value; }
            }
            public String TenDonViSi
            {
                get { return _TenDonViSi; }
                set { _TenDonViSi = value; }
            }
            public String TenDonViLe
            {
                get { return _TenDonViLe; }
                set { _TenDonViLe = value; }
            }
            public String SoLuongConLai
            {
                get { return _SoLuongConLai; }
                set { _SoLuongConLai = value; }
            }
            public String NguongNhap
            {
                get { return _NguongNhap; }
                set { _NguongNhap = value; }
            }
            public String NguongXuat
            {
                get { return _NguongXuat; }
                set { _NguongXuat = value; }
            }
            public bool KhuyenMai
            {
                get { return _KhuyenMai; }
                set { _KhuyenMai = value; }
            }
            public bool TrangThai
            {
                get { return _TrangThai; }
                set { _TrangThai = value; }
            }
        }
        #endregion

        private void usrImage_Click(object sender, EventArgs e)
        {
            InvokeMatHangClick(new MatHangArgs(_MaSP, _TenSP, _HinhSP, _GiaLeSP, _GiaNhap,_GiaQuyDinh, _GiaChiaThang, _GiaKhuyenMai,_QuyCach,_VAT,_MaLoai,_MaDonViSi,_MaDonViLe,_TenDonViSi,_TenDonViLe,_SoLuongConLai,_NguongNhap,_NguongXuat,_KhuyenMai, _TrangThai));
        }

        private void picHinhSP_DoubleClick(object sender, EventArgs e)
        {
            base.OnDoubleClick(e);
        }

        
    }
}
